﻿package src.flip{
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.media.*;
	import flash.net.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	import src.events.*;
	import src.utils.*;
	import src.caurina.transitions.*;
	public final class Helper extends Sprite {
		
		private var flip:Flip = Flip.flip;
		private var config:Object = Flip.config;
		//
		
		public function Helper():void {
			this.visible = false;
			this.filters = Flip.getShadow();
			helper_head.addEventListener(MouseEvent.MOUSE_DOWN, headDownHandler);
			flip.stage.addEventListener(MouseEvent.MOUSE_UP, headUpHandler);
			helper_button.addEventListener(MouseEvent.CLICK, buttonHandler);
			
			flip.addEventListener(FlipEvent.RESIZE, resizeHandler);
			flip.addEventListener(FlipEvent.HELP, helpHandler);
			resizeHandler();
		}
		
		private function buttonHandler(e:MouseEvent):void {
			helpHandler();
		}
		private function headDownHandler(e:MouseEvent):void {
			this.startDrag();
		}
		private function headUpHandler(e:MouseEvent):void {
			this.stopDrag();
		}
		
		private function helpHandler(e:FlipEvent = null):void {
			this.visible = !this.visible;
			this.parent.setChildIndex(this, this.parent.numChildren - 1);
		}

		private function resizeHandler(e:FlipEvent = null):void {
			this.x = (config['width'] - this.width) * 0.5;
			this.y = (config['height'] - this.height) * 0.5;
		}
		
	}
}